package com.firstjianmo.broadcasttest;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

/**
 * Created by pc on 2016/12/4.
 */

public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String msg = intent == null ? "" : intent.getStringExtra("msg");

        if (isOrderedBroadcast()) {
            Bundle bundle = getResultExtras(true);//接收来自上一级优先级较高的广播修改的信息
            msg = bundle.getString("msg");
        }
        Toast.makeText(context, "received in MyBroiadcastReceiver ; " + msg, Toast.LENGTH_LONG).show();
    }
}
